package com.angel.webapp.application;

import com.angel.common.keyValue.KeyValueResult;
import com.angel.common.keyValue.impl.KeyValueResultImpl;
import com.angel.io.processors.commands.imports.ImportRowProcessorCommand;

/**
 * @author William
 * @since 03/February/2009
 */
public class ApplicationImportRowCommands {

    private static ApplicationImportRowCommands INSTANCE;

    private KeyValueResult keyValueResult;

    private ApplicationImportRowCommands(){
        super();
        this.setKeyValueResult(new KeyValueResultImpl());
    }

    public synchronized static ApplicationImportRowCommands createInstance(){
        if(INSTANCE == null){
            INSTANCE = new ApplicationImportRowCommands();
        }
        return INSTANCE;
    }

    public KeyValueResult getKeyValueResult() {
        return keyValueResult;
    }

    public void setKeyValueResult(KeyValueResult keyValueResult) {
        this.keyValueResult = keyValueResult;
    }

    public ImportRowProcessorCommand findImportRowCommand(String name){
        return (ImportRowProcessorCommand) this.getKeyValueResult().getResultFor(name);
    }
    
    public void addImportRowCommand(String name, ImportRowProcessorCommand importRowProcessorCommand){
        this.getKeyValueResult().addKeyValue(name, importRowProcessorCommand);
    }
    
    public void removeImportRowCommand(String name){
        this.getKeyValueResult().removeKeyValue(name);
    }

    public boolean containsImportRowCommand(String name){
        return this.keyValueResult.containsResultFor(name);
    }
}